package com.ddd.framework.dto;

import com.ddd.framework.enums.ResponseCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * SingleResponse
 *  Response with single record to return
 * @author guowm
 * @date 2025-02-08
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SingleResponse<T> extends Response {

    private T data;

    public static <T> SingleResponse<T> success(T data) {
        SingleResponse<T> response = new SingleResponse<>();
        response.setCode(ResponseCode.SUCCESS.getCode());
        response.setMessage(ResponseCode.SUCCESS.getMessage());
        response.setData(data);
        return response;
    }

}
